# Also of interest:
# http://docs.moodle.org/25/en/Programmed_responses_question_type
# http://docs.moodle.org/25/en/question/type/correctwriting -- sakinio struktūros klausimai
# http://docs.moodle.org/25/en/Multinumerical_question_type
# http://docs.moodle.org/dev/Opaque


#~ from random import randint


#~ def Arithmetics_2operations(_sign1='+', _sign2='*', _a=13, _b=5, _c=7):
    #~ __tpl ="""
#~ rez = _a _sign1 _b _sign2 _c
#~ print(rez)
#~ """

try:
    from tpl_helpers import __rand_questions, __print_category
except ImportError:
    from .tpl_helpers import __rand_questions, __print_category
    
    
############ Arithmetics #########

def Arithmetics_simple1(_a, _b, _c):
    """Kam bus lygus x?"""
    x = _a * _b - _c # skaičiuojam HIDEEXACT(*) 
    print (x)

def Arithmetics_simple2(_a, _b, _c):
    """Kam bus lygus x ir y? (atskirkite tarpais)"""
    x = _a - _c
    y = _a + x * _b # HIDEEXACT(* _b)
    print (x, y)

def Arithmetics_simple3(_a, _b, _c):
    """Kam bus lygus x?"""
    a = _a
    b = _b
    x = a - _c * (b - a)
    print (x)

__rand_questions(Arithmetics_simple1, [(1, 9), (3, 9), (1, 9)], 5 )
__rand_questions(Arithmetics_simple2, [(1, 9), (3, 9), (1, 9)], 5 )
__rand_questions(Arithmetics_simple3, [(1, 9), (3, 9), (1, 9)], 5 )



############ Variables #########    

def Var_Arithmetic_PlusMult(_a=2, _b=5, _c=3): # {=%(track['x'])s}
    """Ką atspausdins?"""
    x = _a
    x = x + _b  # HIDE(+)
    print(x)
    x = _c * x # HIDE(*)
    print(x)
    

def Variables_simple1(_a, _b):
    """Kiek pinigų turėsime pabaigoje?"""
    pinigai = _a # pradinė piginų suma
    kebabas = _b
    pinigai = pinigai - kebabas  # kintamojo pakeitimas 
    print (pinigai)

def Variables_simple2(_a, _b):
    """Kiek nupirks porcijų ir kiek liks pinigų?"""
    pinigai = _a # pradinė piginų suma
    kebabas = _b # kebabo kaina
    porcijos = pinigai // kebabas  # suapvalinanti dalyba
    pinigai = pinigai - porcijos*kebabas  # likutis
    print (porcijos, pinigai)



def Variables_and_IF1(_a, _b, _c):
    """Kiek nupirks porcijų ir kiek liks pinigų?"""
    pinigai = _a # pradinė piginų suma
    kebabas = _b # kebabo kaina
    draugai = _c
    porcijos = pinigai // kebabas  # suapvalinanti dalyba "//"
    if porcijos > draugai+1:  
        porcijos = draugai+1  # užteks kiekvienam po vieną porciją
    islaidos = porcijos * kebabas
    pinigai = pinigai - islaidos
    
    print (porcijos, pinigai)

    
__rand_questions(    Var_Arithmetic_PlusMult, [(-9, 9), (2, 9), (3, 9)], 5 )
__rand_questions(    Variables_simple1, [(10, 20), (2, 9)], 5 )
__rand_questions(    Variables_simple2, [(10, 30), (3, 7)], 5)
__rand_questions(    Variables_and_IF1, [(10, 50), (3, 7), (0, 5)], 7 )


################ IF ELIF #############
def IfElifElse(_a, _b=12, _c=8): # {=%(out)s}
    """What will be printed?"""
    a = _a
    if a > _b:
        print("big")
    elif a > _c:
        print("average")
    else:
        print("small")  
    

# the variations of question
__print_category('IfElifElse_FIXED')
IfElifElse(10, 18)
IfElifElse(10, 18, 10)
IfElifElse(12, 12, 10)
IfElifElse(5, 12, 10)
IfElifElse(15, 12, 10)

__rand_questions(   IfElifElse,  [(10, 99), (10, 99), (10, 99)], 5)
#~ for i in range(5):
    #~ IfElifElse( randint(10, 99), randint(10, 99), randint(10, 99) )
